<?php
	if($_SERVER["REQUEST_METHOD"]=="POST") {
	if (empty($_SESSION['captcha']) || trim(strtolower($_REQUEST['captcha'])) != $_SESSION['captcha']) {
			sleep(3);
			echo '<script type="text/javascript">alert("invalid captcha");</script>';
		} else {
			$username	= strip_tags($_POST['username']);
			$password	= strip_tags($_POST['password']);
			$first_name	= strip_tags($_POST['first_name']);
			$last_name	= strip_tags($_POST['last_name']);
			$member_scid= strip_tags($_POST['member_scid']);
			$email		= strip_tags($_POST['email']);
			$gender		= strip_tags($_POST['gender']);
			$birthday	= strip_tags($_POST['birthday']);
			$company	= strip_tags($_POST['company']);
			$address	= strip_tags($_POST['address']);
			$road		= strip_tags($_POST['road']);
			$soi		= strip_tags($_POST['soi']);
			$subdistrict= strip_tags($_POST['subdistrict']);
			$district	= strip_tags($_POST['district']);
			$province	= strip_tags($_POST['province']);
			$postcode	= strip_tags($_POST['postcode']);
			$telephone	= strip_tags($_POST['telephone']);
			$ip			= getUserIP();
		 
			
			$sql = "INSERT INTO `tbl_member` (`member_id`, `username`, `password`, `first_name`, `last_name`, `member_scid`,`email`, `gender`, `birthday`, `company`, `address`, `road`, `soi`, `subdistrict`, `district`, `province`, `postcode`, `telephone`, `ip`, `ssid`, `date`, `update`,`activate`, `status`) VALUES (NULL, '$username', '$password', '$first_name', '$last_name', '$member_scid','$email', '$gender', '$birthday', '$company', '$address', '$road', '$soi', '$subdistrict', '$district', '$province', '$postcode', '$telephone', '$ip', '$ss_id', NOW(),NOW(), '1', '1');";
			mysql_query($sql);
			
/*
			$temp_member_id				= mysql_insert_id();
			$tp_mail	= new template(VIEW_ABS . '/profile/activate-email.html');
			$key		= 'zvv';
			$encmd5		= md5($temp_member_id.$key);
			$m_username	= $first_name.' '.$last_name;
			$mail_html	= $tp_mail->generate();

			include('libs/phpmailer/class.phpmailer.php');

			$mail = new PHPMailer();
			$mail->CharSet	= "utf-8";
			$mail->From     = "webmaster@ss.com";
			$mail->FromName = " ";
			$mail->Subject	= "Activate: ";
			$mail->IsHTML(true);
			$mail->Body		= $mail_html;
			$mail->AddAddress($email, $m_username);
			$mail->Send();
			$mail->ClearAddresses();
				

*/
			header("Location: /");
			exit;
		 
		}
	}

	$provinceOptions = _u(sqlOptions('SELECT `TH` AS `label` , `province_id` AS `value` FROM `province` WHERE 1 ORDER BY `province_id` ASC; '),'province')
?>